Add gboolean return values and GError arguments to ::set_current_folder()
authorFederico Mena Quintero <federico@ximian.com>
Fri, 5 Mar 2004 20:47:05 +0000 (20:47 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Fri, 5 Mar 2004 20:47:05 +0000 (20:47 +0000)
2004-03-05  Federico Mena Quintero  <federico@ximian.com>

* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
gboolean return values and GError arguments to
::set_current_folder() and ::select_path().

* gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
Return a boolean value for success/failure.
(gtk_file_chooser_set_current_folder_uri): Likewise.
(gtk_file_chooser_select_filename): Likewise.
(gtk_file_chooser_select_uri): Likewise.
(gtk_file_chooser_set_filename): Likewise.
(gtk_file_chooser_set_uri): Likewise.
(_gtk_file_chooser_set_current_folder_path): Likewise, plus take
in a GError.
(_gtk_file_chooser_select_path): Likewise.

* gtk/gtkfilechooserutils.c (delegate_set_current_folder):
Likewise.
(delegate_select_path): Likewise.

* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_select_path): Likewise.
(gtk_file_chooser_default_set_current_folder): Likewise.
(error_changing_folder_dialog): New helper function.
(change_folder_and_display_error): New helper function.
(switch_to_selected_folder): Use change_folder_and_display_error().
(tree_selection_changed): Likewise.
(shortcuts_activate_volume): Likewise.
(shortcuts_activate_item): Likewise.
(list_row_activated): Likewise.
(path_bar_clicked): Likewise.
(update_from_entry): Likewise.
(up_folder_handler): Likewise.
(home_folder_handler): Get the home path from the shortcuts model,
and use change_folder_and_display_error().

* tests/testfilechooser.c (set_current_folder): New helper
function; pops up a simple error dialog if necessary.
(set_filename): Likewise.
(set_folder_nonexistent_cb): Use set_current_folder().
(set_folder_existing_nonexistent_cb): Likewise.
(set_filename_nonexistent_cb): Use set_filename().
(set_filename_existing_nonexistent_cb): Likewise.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooser.c
gtk/gtkfilechooser.h
gtk/gtkfilechooserdefault.c
gtk/gtkfilechooserprivate.h
gtk/gtkfilechooserutils.c

index b3f519fb1f65f0260fba2fe162d7ec2d009ae94d..b79cdb36a892f570cb941e79df8eb6b4e49c0052 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,48 @@
+2004-03-05  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+       gboolean return values and GError arguments to
+       ::set_current_folder() and ::select_path().
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+       Return a boolean value for success/failure.
+       (gtk_file_chooser_set_current_folder_uri): Likewise.
+       (gtk_file_chooser_select_filename): Likewise.
+       (gtk_file_chooser_select_uri): Likewise.
+       (gtk_file_chooser_set_filename): Likewise.
+       (gtk_file_chooser_set_uri): Likewise.
+       (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+       in a GError.
+       (_gtk_file_chooser_select_path): Likewise.
+
+       * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+       Likewise.
+       (delegate_select_path): Likewise.
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_select_path): Likewise.
+       (gtk_file_chooser_default_set_current_folder): Likewise.
+       (error_changing_folder_dialog): New helper function.
+       (change_folder_and_display_error): New helper function.
+       (switch_to_selected_folder): Use change_folder_and_display_error().
+       (tree_selection_changed): Likewise.
+       (shortcuts_activate_volume): Likewise.
+       (shortcuts_activate_item): Likewise.
+       (list_row_activated): Likewise.
+       (path_bar_clicked): Likewise.
+       (update_from_entry): Likewise.
+       (up_folder_handler): Likewise.
+       (home_folder_handler): Get the home path from the shortcuts model,
+       and use change_folder_and_display_error().
+
+       * tests/testfilechooser.c (set_current_folder): New helper
+       function; pops up a simple error dialog if necessary.
+       (set_filename): Likewise.
+       (set_folder_nonexistent_cb): Use set_current_folder().
+       (set_folder_existing_nonexistent_cb): Likewise.
+       (set_filename_nonexistent_cb): Use set_filename().
+       (set_filename_existing_nonexistent_cb): Likewise.
+
 Fri Mar  5 11:17:35 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): 
index b3f519fb1f65f0260fba2fe162d7ec2d009ae94d..b79cdb36a892f570cb941e79df8eb6b4e49c0052 100644 (file)
@@ -1,3 +1,48 @@
+2004-03-05  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+       gboolean return values and GError arguments to
+       ::set_current_folder() and ::select_path().
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+       Return a boolean value for success/failure.
+       (gtk_file_chooser_set_current_folder_uri): Likewise.
+       (gtk_file_chooser_select_filename): Likewise.
+       (gtk_file_chooser_select_uri): Likewise.
+       (gtk_file_chooser_set_filename): Likewise.
+       (gtk_file_chooser_set_uri): Likewise.
+       (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+       in a GError.
+       (_gtk_file_chooser_select_path): Likewise.
+
+       * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+       Likewise.
+       (delegate_select_path): Likewise.
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_select_path): Likewise.
+       (gtk_file_chooser_default_set_current_folder): Likewise.
+       (error_changing_folder_dialog): New helper function.
+       (change_folder_and_display_error): New helper function.
+       (switch_to_selected_folder): Use change_folder_and_display_error().
+       (tree_selection_changed): Likewise.
+       (shortcuts_activate_volume): Likewise.
+       (shortcuts_activate_item): Likewise.
+       (list_row_activated): Likewise.
+       (path_bar_clicked): Likewise.
+       (update_from_entry): Likewise.
+       (up_folder_handler): Likewise.
+       (home_folder_handler): Get the home path from the shortcuts model,
+       and use change_folder_and_display_error().
+
+       * tests/testfilechooser.c (set_current_folder): New helper
+       function; pops up a simple error dialog if necessary.
+       (set_filename): Likewise.
+       (set_folder_nonexistent_cb): Use set_current_folder().
+       (set_folder_existing_nonexistent_cb): Likewise.
+       (set_filename_nonexistent_cb): Use set_filename().
+       (set_filename_existing_nonexistent_cb): Likewise.
+
 Fri Mar  5 11:17:35 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): 
index b3f519fb1f65f0260fba2fe162d7ec2d009ae94d..b79cdb36a892f570cb941e79df8eb6b4e49c0052 100644 (file)
@@ -1,3 +1,48 @@
+2004-03-05  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+       gboolean return values and GError arguments to
+       ::set_current_folder() and ::select_path().
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+       Return a boolean value for success/failure.
+       (gtk_file_chooser_set_current_folder_uri): Likewise.
+       (gtk_file_chooser_select_filename): Likewise.
+       (gtk_file_chooser_select_uri): Likewise.
+       (gtk_file_chooser_set_filename): Likewise.
+       (gtk_file_chooser_set_uri): Likewise.
+       (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+       in a GError.
+       (_gtk_file_chooser_select_path): Likewise.
+
+       * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+       Likewise.
+       (delegate_select_path): Likewise.
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_select_path): Likewise.
+       (gtk_file_chooser_default_set_current_folder): Likewise.
+       (error_changing_folder_dialog): New helper function.
+       (change_folder_and_display_error): New helper function.
+       (switch_to_selected_folder): Use change_folder_and_display_error().
+       (tree_selection_changed): Likewise.
+       (shortcuts_activate_volume): Likewise.
+       (shortcuts_activate_item): Likewise.
+       (list_row_activated): Likewise.
+       (path_bar_clicked): Likewise.
+       (update_from_entry): Likewise.
+       (up_folder_handler): Likewise.
+       (home_folder_handler): Get the home path from the shortcuts model,
+       and use change_folder_and_display_error().
+
+       * tests/testfilechooser.c (set_current_folder): New helper
+       function; pops up a simple error dialog if necessary.
+       (set_filename): Likewise.
+       (set_folder_nonexistent_cb): Use set_current_folder().
+       (set_folder_existing_nonexistent_cb): Likewise.
+       (set_filename_nonexistent_cb): Use set_filename().
+       (set_filename_existing_nonexistent_cb): Likewise.
+
 Fri Mar  5 11:17:35 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): 
index b3f519fb1f65f0260fba2fe162d7ec2d009ae94d..b79cdb36a892f570cb941e79df8eb6b4e49c0052 100644 (file)
@@ -1,3 +1,48 @@
+2004-03-05  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+       gboolean return values and GError arguments to
+       ::set_current_folder() and ::select_path().
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+       Return a boolean value for success/failure.
+       (gtk_file_chooser_set_current_folder_uri): Likewise.
+       (gtk_file_chooser_select_filename): Likewise.
+       (gtk_file_chooser_select_uri): Likewise.
+       (gtk_file_chooser_set_filename): Likewise.
+       (gtk_file_chooser_set_uri): Likewise.
+       (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+       in a GError.
+       (_gtk_file_chooser_select_path): Likewise.
+
+       * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+       Likewise.
+       (delegate_select_path): Likewise.
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_select_path): Likewise.
+       (gtk_file_chooser_default_set_current_folder): Likewise.
+       (error_changing_folder_dialog): New helper function.
+       (change_folder_and_display_error): New helper function.
+       (switch_to_selected_folder): Use change_folder_and_display_error().
+       (tree_selection_changed): Likewise.
+       (shortcuts_activate_volume): Likewise.
+       (shortcuts_activate_item): Likewise.
+       (list_row_activated): Likewise.
+       (path_bar_clicked): Likewise.
+       (update_from_entry): Likewise.
+       (up_folder_handler): Likewise.
+       (home_folder_handler): Get the home path from the shortcuts model,
+       and use change_folder_and_display_error().
+
+       * tests/testfilechooser.c (set_current_folder): New helper
+       function; pops up a simple error dialog if necessary.
+       (set_filename): Likewise.
+       (set_folder_nonexistent_cb): Use set_current_folder().
+       (set_folder_existing_nonexistent_cb): Likewise.
+       (set_filename_nonexistent_cb): Use set_filename().
+       (set_filename_existing_nonexistent_cb): Likewise.
+
 Fri Mar  5 11:17:35 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): 
index b3f519fb1f65f0260fba2fe162d7ec2d009ae94d..b79cdb36a892f570cb941e79df8eb6b4e49c0052 100644 (file)
@@ -1,3 +1,48 @@
+2004-03-05  Federico Mena Quintero  <federico@ximian.com>
+
+       * gtk/gtkfilechooserprivate.h (struct _GtkFileChooserIface): Add
+       gboolean return values and GError arguments to
+       ::set_current_folder() and ::select_path().
+
+       * gtk/gtkfilechooser.c (gtk_file_chooser_set_current_folder):
+       Return a boolean value for success/failure.
+       (gtk_file_chooser_set_current_folder_uri): Likewise.
+       (gtk_file_chooser_select_filename): Likewise.
+       (gtk_file_chooser_select_uri): Likewise.
+       (gtk_file_chooser_set_filename): Likewise.
+       (gtk_file_chooser_set_uri): Likewise.
+       (_gtk_file_chooser_set_current_folder_path): Likewise, plus take
+       in a GError.
+       (_gtk_file_chooser_select_path): Likewise.
+
+       * gtk/gtkfilechooserutils.c (delegate_set_current_folder):
+       Likewise.
+       (delegate_select_path): Likewise.
+
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_select_path): Likewise.
+       (gtk_file_chooser_default_set_current_folder): Likewise.
+       (error_changing_folder_dialog): New helper function.
+       (change_folder_and_display_error): New helper function.
+       (switch_to_selected_folder): Use change_folder_and_display_error().
+       (tree_selection_changed): Likewise.
+       (shortcuts_activate_volume): Likewise.
+       (shortcuts_activate_item): Likewise.
+       (list_row_activated): Likewise.
+       (path_bar_clicked): Likewise.
+       (update_from_entry): Likewise.
+       (up_folder_handler): Likewise.
+       (home_folder_handler): Get the home path from the shortcuts model,
+       and use change_folder_and_display_error().
+
+       * tests/testfilechooser.c (set_current_folder): New helper
+       function; pops up a simple error dialog if necessary.
+       (set_filename): Likewise.
+       (set_folder_nonexistent_cb): Use set_current_folder().
+       (set_folder_existing_nonexistent_cb): Likewise.
+       (set_filename_nonexistent_cb): Use set_filename().
+       (set_filename_existing_nonexistent_cb): Likewise.
+
 Fri Mar  5 11:17:35 2004  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): 
index f1bc3a99939fb67dd7f6d696b9d182dff2c97514..9497da21f856b0d4886e6667fc66f0148ea605d6 100644 (file)
@@ -359,16 +359,19 @@ gtk_file_chooser_get_filename (GtkFileChooser *chooser)
  * for the directory change. To pre-enter a filename for the user, as in
  * a save-as dialog, use gtk_file_chooser_set_current_name()
  *
+ * Return value: %TRUE if both the folder could be changed and the file was
+ * selected successfully, %FALSE otherwise.
+ *
  * Since: 2.4
  **/
-void
+gboolean
 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
                               const gchar    *filename)
 {
-  g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
 
   gtk_file_chooser_unselect_all (chooser);
-  gtk_file_chooser_select_filename (chooser, filename);
+  return gtk_file_chooser_select_filename (chooser, filename);
 }
 
 /**
@@ -380,26 +383,34 @@ gtk_file_chooser_set_filename (GtkFileChooser *chooser,
  * folder of @chooser, then the current folder of @chooser will
  * be changed to the folder containing @filename.
  *
+ * Return value: %TRUE if both the folder could be changed and the file was
+ * selected successfully, %FALSE otherwise.
+ *
  * Since: 2.4
  **/
-void
+gboolean
 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
                                  const gchar    *filename)
 {
   GtkFileSystem *file_system;
   GtkFilePath *path;
+  gboolean result;
   
-  g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
-  g_return_if_fail (filename != NULL);
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+  g_return_val_if_fail (filename != NULL, FALSE);
 
   file_system = _gtk_file_chooser_get_file_system (chooser);
 
   path = gtk_file_system_filename_to_path (file_system, filename);
   if (path)
     {
-      _gtk_file_chooser_select_path (chooser, path);
+      result = _gtk_file_chooser_select_path (chooser, path, NULL);
       gtk_file_path_free (path);
     }
+  else
+    result = FALSE;
+
+  return result;
 }
 
 /**
@@ -499,26 +510,34 @@ gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
  * The user will be shown the full contents of the current folder,
  * plus user interface elements for navigating to other folders.
  *
+ * Return value: %TRUE if the folder could be changed successfully, %FALSE
+ * otherwise.
+ *
  * Since: 2.4
  **/
-void
+gboolean
 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
                                     const gchar    *filename)
 {
   GtkFileSystem *file_system;
   GtkFilePath *path;
+  gboolean result;
   
-  g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
-  g_return_if_fail (filename != NULL);
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+  g_return_val_if_fail (filename != NULL, FALSE);
 
   file_system = _gtk_file_chooser_get_file_system (chooser);
 
   path = gtk_file_system_filename_to_path (file_system, filename);
   if (path)
     {
-      _gtk_file_chooser_set_current_folder_path (chooser, path);
+      result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
       gtk_file_path_free (path);
     }
+  else
+    result = FALSE;
+
+  return result;
 }
 
 /**
@@ -628,16 +647,19 @@ gtk_file_chooser_get_uri (GtkFileChooser *chooser)
  * for the directory change. To pre-enter a filename for the user, as in
  * a save-as dialog, use gtk_file_chooser_set_current_name()
  *
+ * Return value: %TRUE if both the folder could be changed and the URI was
+ * selected successfully, %FALSE otherwise.
+ *
  * Since: 2.4
  **/
-void
+gboolean
 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
                          const char     *uri)
 {
-  g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
 
   gtk_file_chooser_unselect_all (chooser);
-  gtk_file_chooser_select_uri (chooser, uri);
+  return gtk_file_chooser_select_uri (chooser, uri);
 }
 
 /**
@@ -649,26 +671,34 @@ gtk_file_chooser_set_uri (GtkFileChooser *chooser,
  * file in the current folder of @chooser, then the current folder of
  * @chooser will be changed to the folder containing @filename.
  *
+ * Return value: %TRUE if both the folder could be changed and the URI was
+ * selected successfully, %FALSE otherwise.
+ *
  * Since: 2.4
  **/
-void
+gboolean
 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
                             const char     *uri)
 {
   GtkFileSystem *file_system;
   GtkFilePath *path;
+  gboolean result;
   
-  g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
-  g_return_if_fail (uri != NULL);
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+  g_return_val_if_fail (uri != NULL, FALSE);
 
   file_system = _gtk_file_chooser_get_file_system (chooser);
 
   path = gtk_file_system_uri_to_path (file_system, uri);
   if (path)
     {
-      _gtk_file_chooser_select_path (chooser, path);
+      result = _gtk_file_chooser_select_path (chooser, path, NULL);
       gtk_file_path_free (path);
     }
+  else
+    result = FALSE;
+
+  return result;
 }
 
 /**
@@ -774,26 +804,34 @@ gtk_file_chooser_get_uris (GtkFileChooser *chooser)
  * The user will be shown the full contents of the current folder,
  * plus user interface elements for navigating to other folders.
  *
+ * Return value: %TRUE if the folder could be changed successfully, %FALSE
+ * otherwise.
+ *
  * Since: 2.4
  **/
-void
+gboolean
 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
                                         const gchar    *uri)
 {
   GtkFileSystem *file_system;
   GtkFilePath *path;
+  gboolean result;
   
-  g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
-  g_return_if_fail (uri != NULL);
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+  g_return_val_if_fail (uri != NULL, FALSE);
 
   file_system = _gtk_file_chooser_get_file_system (chooser);
 
   path = gtk_file_system_uri_to_path (file_system, uri);
   if (path)
     {
-      _gtk_file_chooser_set_current_folder_path (chooser, path);
+      result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
       gtk_file_path_free (path);
     }
+  else
+    result = FALSE;
+
+  return result;
 }
 
 /**
@@ -830,20 +868,26 @@ gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
  * _gtk_file_chooser_set_current_folder_path:
  * @chooser: a #GtkFileChooser
  * @path: the #GtkFilePath for the new folder
+ * @error: location to store error, or %NULL.
  * 
  * Sets the current folder for @chooser from a #GtkFilePath.
  * Internal function, see gtk_file_chooser_set_current_folder_uri().
  *
+ * Return value: %TRUE if the folder could be changed successfully, %FALSE
+ * otherwise.
+ *
  * Since: 2.4
  **/
-void
+gboolean
 _gtk_file_chooser_set_current_folder_path (GtkFileChooser    *chooser,
-                                          const GtkFilePath *path)
+                                          const GtkFilePath *path,
+                                          GError           **error)
 {
-  g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
-  g_return_if_fail (path != NULL);
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+  g_return_val_if_fail (path != NULL, FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-  GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path);
+  return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
 }
 
 /**
@@ -870,19 +914,26 @@ _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
  * _gtk_file_chooser_select_path:
  * @chooser: a #GtkFileChooser
  * @path: the path to select
+ * @error: location to store error, or %NULL
  * 
  * Selects the file referred to by @path. An internal function. See
  * _gtk_file_chooser_select_uri().
  *
+ * Return value: %TRUE if both the folder could be changed and the path was
+ * selected successfully, %FALSE otherwise.
+ *
  * Since: 2.4
  **/
-void
+gboolean
 _gtk_file_chooser_select_path (GtkFileChooser    *chooser,
-                              const GtkFilePath *path)
+                              const GtkFilePath *path,
+                              GError           **error)
 {
-  g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
+  g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
+  g_return_val_if_fail (path != NULL, FALSE);
+  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-  GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path);
+  return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
 }
 
 /**
index 5192a2835b51512f5eefa83bf8e2f299a6799bd2..26db8456ee01bdd6a7134386d732f50d2fc6b6fe 100644 (file)
@@ -65,39 +65,41 @@ void                 gtk_file_chooser_set_select_multiple (GtkFileChooser
                                                           gboolean              select_multiple);
 gboolean             gtk_file_chooser_get_select_multiple (GtkFileChooser       *chooser);
 
+/* Suggested name for the Save-type actions
+ */
+void     gtk_file_chooser_set_current_name   (GtkFileChooser *chooser,
+                                             const gchar    *name);
+
 /* Filename manipulation
  */
-void    gtk_file_chooser_set_current_name  (GtkFileChooser *chooser,
-                                           const gchar    *name);
-gchar * gtk_file_chooser_get_filename      (GtkFileChooser *chooser);
-void    gtk_file_chooser_set_filename      (GtkFileChooser *chooser,
-                                           const char     *filename);
-void    gtk_file_chooser_select_filename   (GtkFileChooser *chooser,
-                                           const char     *filename);
-void    gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
-                                           const char     *filename);
-void    gtk_file_chooser_select_all        (GtkFileChooser *chooser);
-void    gtk_file_chooser_unselect_all      (GtkFileChooser *chooser);
-GSList *gtk_file_chooser_get_filenames     (GtkFileChooser *chooser);
-void   gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
-                                           const gchar    *filename);
-gchar *gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
+gchar *  gtk_file_chooser_get_filename       (GtkFileChooser *chooser);
+gboolean gtk_file_chooser_set_filename       (GtkFileChooser *chooser,
+                                             const char     *filename);
+gboolean gtk_file_chooser_select_filename    (GtkFileChooser *chooser,
+                                             const char     *filename);
+void     gtk_file_chooser_unselect_filename  (GtkFileChooser *chooser,
+                                             const char     *filename);
+void     gtk_file_chooser_select_all         (GtkFileChooser *chooser);
+void     gtk_file_chooser_unselect_all       (GtkFileChooser *chooser);
+GSList * gtk_file_chooser_get_filenames      (GtkFileChooser *chooser);
+gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
+                                             const gchar    *filename);
+gchar *  gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
 
 
 /* URI manipulation
  */
-gchar * gtk_file_chooser_get_uri      (GtkFileChooser *chooser);
-void    gtk_file_chooser_set_uri      (GtkFileChooser *chooser,
-                                      const char     *uri);
-void    gtk_file_chooser_select_uri   (GtkFileChooser *chooser,
-                                      const char     *uri);
-void    gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
-                                      const char     *uri);
-GSList *gtk_file_chooser_get_uris     (GtkFileChooser *chooser);
-
-void   gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
-                                               const gchar    *uri);
-gchar *gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
+gchar *  gtk_file_chooser_get_uri                (GtkFileChooser *chooser);
+gboolean gtk_file_chooser_set_uri                (GtkFileChooser *chooser,
+                                                 const char     *uri);
+gboolean gtk_file_chooser_select_uri             (GtkFileChooser *chooser,
+                                                 const char     *uri);
+void     gtk_file_chooser_unselect_uri           (GtkFileChooser *chooser,
+                                                 const char     *uri);
+GSList * gtk_file_chooser_get_uris               (GtkFileChooser *chooser);
+gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
+                                                 const gchar    *uri);
+gchar *  gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
 
 /* Preview widget
  */
index 4451e3d8c9ba2e86f4fb43aa4bbb2d86d63f6297..997925aaaf8d24908e5c0a4cf4646ce5ed39df44 100644 (file)
@@ -241,13 +241,15 @@ static void     gtk_file_chooser_default_style_set      (GtkWidget             *
 static void     gtk_file_chooser_default_screen_changed (GtkWidget             *widget,
                                                         GdkScreen             *previous_screen);
 
-static void           gtk_file_chooser_default_set_current_folder         (GtkFileChooser    *chooser,
-                                                                           const GtkFilePath *path);
+static gboolean       gtk_file_chooser_default_set_current_folder         (GtkFileChooser    *chooser,
+                                                                           const GtkFilePath *path,
+                                                                           GError           **error);
 static GtkFilePath *  gtk_file_chooser_default_get_current_folder         (GtkFileChooser    *chooser);
 static void           gtk_file_chooser_default_set_current_name           (GtkFileChooser    *chooser,
                                                                            const gchar       *name);
-static void           gtk_file_chooser_default_select_path                (GtkFileChooser    *chooser,
-                                                                           const GtkFilePath *path);
+static gboolean       gtk_file_chooser_default_select_path                (GtkFileChooser    *chooser,
+                                                                           const GtkFilePath *path,
+                                                                           GError           **error);
 static void           gtk_file_chooser_default_unselect_path              (GtkFileChooser    *chooser,
                                                                            const GtkFilePath *path);
 static void           gtk_file_chooser_default_select_all                 (GtkFileChooser    *chooser);
@@ -663,6 +665,35 @@ error_building_filename_dialog (GtkFileChooserDefault *impl,
   g_error_free (error);
 }
 
+/* Shows an error dialog when we cannot switch to a folder */
+static void
+error_changing_folder_dialog (GtkFileChooserDefault *impl,
+                             const GtkFilePath     *path,
+                             GError                *error)
+{
+  error_dialog (impl,
+               _("Could not change the current folder to %s:\n%s"),
+               path,
+               error);
+}
+
+/* Changes folders, displaying an error dialog if this fails */
+static gboolean
+change_folder_and_display_error (GtkFileChooserDefault *impl,
+                                const GtkFilePath     *path)
+{
+  GError *error;
+  gboolean result;
+
+  error = NULL;
+  result = _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path, &error);
+
+  if (!result)
+    error_changing_folder_dialog (impl, path, error);
+
+  return result;
+}
+
 static void
 update_preview_widget_visibility (GtkFileChooserDefault *impl)
 {
@@ -1108,7 +1139,7 @@ shortcuts_add_current_folder (GtkFileChooserDefault *impl)
        base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
       else
        base_path = NULL;
-      
+
       if (base_path &&
          strcmp (gtk_file_path_get_string (base_path), gtk_file_path_get_string (impl->current_folder)) == 0)
        {
@@ -2919,20 +2950,19 @@ update_chooser_entry (GtkFileChooserDefault *impl)
                        gtk_file_info_get_display_name (info));
 }
 
-static void
+static gboolean
 gtk_file_chooser_default_set_current_folder (GtkFileChooser    *chooser,
-                                            const GtkFilePath *path)
+                                            const GtkFilePath *path,
+                                            GError           **error)
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
-  GError *error;
+  GError *err;
 
-  error = NULL;
-  if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, impl->file_system, &error))
+  err = NULL;
+  if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, impl->file_system, &err))
     {
-      error_dialog (impl,
-                   _("Could not set current folder: %s"),
-                   path, error);
-      return;
+      g_propagate_error (error, err);
+      return FALSE;
     }
 
   if (impl->current_folder != path)
@@ -2971,6 +3001,8 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser    *chooser,
   bookmarks_check_add_sensitivity (impl);
 
   g_signal_emit_by_name (impl, "selection-changed", 0);
+
+  return TRUE;
 }
 
 static GtkFilePath *
@@ -3008,32 +3040,37 @@ select_func (GtkFileSystemModel *model,
   gtk_tree_path_free (sorted_path);
 }
 
-static void
+static gboolean
 gtk_file_chooser_default_select_path (GtkFileChooser    *chooser,
-                                     const GtkFilePath *path)
+                                     const GtkFilePath *path,
+                                     GError           **error)
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
   GtkFilePath *parent_path;
-  GError *error;
+  GError *err;
 
-  error = NULL;
-  if (!gtk_file_system_get_parent (impl->file_system, path, &parent_path, &error))
+  err = NULL;
+  if (!gtk_file_system_get_parent (impl->file_system, path, &parent_path, &err))
     {
-      error_getting_info_dialog (impl, path, error);
-      return;
+      g_propagate_error (error, err);
+      return FALSE;
     }
 
   if (!parent_path)
-    {
-      _gtk_file_chooser_set_current_folder_path (chooser, path);
-    }
+    return _gtk_file_chooser_set_current_folder_path (chooser, path, error);
   else
     {
-      _gtk_file_chooser_set_current_folder_path (chooser, parent_path);
+      gboolean result;
+
+      result = _gtk_file_chooser_set_current_folder_path (chooser, parent_path, error);
       gtk_file_path_free (parent_path);
       _gtk_file_system_model_path_do (impl->browse_files_model, path,
                                      select_func, impl);
+
+      return result;
     }
+
+  g_assert_not_reached ();
 }
 
 static void
@@ -3537,7 +3574,7 @@ switch_to_selected_folder (GtkFileChooserDefault *impl)
 
   g_assert (closure.path && closure.num_selected == 1);
 
-  _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), closure.path);
+  change_folder_and_display_error (impl, closure.path);
 }
 
 /* Implementation for GtkFileChooserEmbed::should_respond() */
@@ -3796,7 +3833,7 @@ tree_selection_changed (GtkTreeSelection      *selection,
   gtk_tree_path_free (path);
 
   if (!impl->changing_folder)
-    _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+    change_folder_and_display_error (impl, file_path);
 }
 
 /* Activates a volume by mounting it if necessary and then switching to its
@@ -3829,7 +3866,7 @@ shortcuts_activate_volume (GtkFileChooserDefault *impl,
     }
 
   path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
-  _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path);
+  change_folder_and_display_error (impl, path);
   gtk_file_path_free (path);
 }
 
@@ -3868,10 +3905,10 @@ shortcuts_activate_item (GtkFileChooserDefault *impl,
     }
   else
     {
-      GtkFilePath *file_path;
+      const GtkFilePath *file_path;
 
       file_path = data;
-      _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+      change_folder_and_display_error (impl, file_path);
     }
 }
 
@@ -3969,7 +4006,7 @@ list_row_activated (GtkTreeView           *tree_view,
       const GtkFilePath *file_path;
 
       file_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
-      _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+      change_folder_and_display_error (impl, file_path);
 
       return;
     }
@@ -3982,7 +4019,7 @@ path_bar_clicked (GtkPathBar            *path_bar,
                  GtkFilePath           *file_path,
                  GtkFileChooserDefault *impl)
 {
-  _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+  change_folder_and_display_error (impl, file_path);
 }
 
 static const GtkFileInfo *
@@ -4206,7 +4243,7 @@ update_from_entry (GtkFileChooserDefault *impl,
 
   if (file_part[0] == '\0')
     {
-      _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), folder_path);
+      change_folder_and_display_error (impl, folder_path);
       return;
     }
   else
@@ -4267,9 +4304,18 @@ update_from_entry (GtkFileChooserDefault *impl,
        }
 
       if (gtk_file_info_get_is_folder (info))
-       _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), subfolder_path);
+       change_folder_and_display_error (impl, subfolder_path);
       else
-       _gtk_file_chooser_select_path (GTK_FILE_CHOOSER (impl), subfolder_path);
+       {
+         GError *error;
+
+         error = NULL;
+         if (!_gtk_file_chooser_select_path (GTK_FILE_CHOOSER (impl), subfolder_path, &error))
+           error_dialog (impl,
+                         _("Could not select %s:\n%s"),
+                         subfolder_path,
+                         error);
+       }
 
       g_object_unref (folder);
       gtk_file_path_free (subfolder_path);
@@ -4335,7 +4381,7 @@ up_folder_handler (GtkFileChooserDefault *impl)
     {
       if (parent_path) /* If we were on a root, parent_path will be NULL */
        {
-         _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), parent_path);
+         change_folder_and_display_error (impl, parent_path);
          gtk_file_path_free (parent_path);
        }
     }
@@ -4350,12 +4396,19 @@ up_folder_handler (GtkFileChooserDefault *impl)
 static void
 home_folder_handler (GtkFileChooserDefault *impl)
 {
-  const char *home;
+  int pos;
+  GtkTreeIter iter;
+  GtkFilePath *path;
 
-  /* Should we pull this information from impl->has_home and the shortcuts data
-   * instead?  Sounds like a bit of overkill...
-   */
+  if (!impl->has_home)
+    return; /* Should we put up an error dialog? */
 
-  home = g_get_home_dir ();
-  gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (impl), home);
+  pos = shortcuts_get_index (impl, SHORTCUTS_HOME);
+  if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
+    g_assert_not_reached ();
+
+  gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter, SHORTCUTS_COL_PATH, &path, -1);
+  g_assert (path != NULL);
+
+  change_folder_and_display_error (impl, path);
 }
index 1e0d97da37ed969945a84876764409b8c0849674..2826f2a1011f3bb815ed8f397f7ddfaa98c5031f 100644 (file)
@@ -36,13 +36,15 @@ struct _GtkFileChooserIface
 
   /* Methods
    */
-  void           (*set_current_folder)            (GtkFileChooser    *chooser,
-                                           const GtkFilePath *path);
+  gboolean       (*set_current_folder)            (GtkFileChooser    *chooser,
+                                           const GtkFilePath *path,
+                                           GError           **error);
   GtkFilePath *  (*get_current_folder)            (GtkFileChooser    *chooser);
   void           (*set_current_name)              (GtkFileChooser    *chooser,
                                            const gchar       *name);
-  void           (*select_path)                   (GtkFileChooser    *chooser,
-                                           const GtkFilePath *path);
+  gboolean       (*select_path)                   (GtkFileChooser    *chooser,
+                                           const GtkFilePath *path,
+                                           GError           **error);
   void           (*unselect_path)                 (GtkFileChooser    *chooser,
                                            const GtkFilePath *path);
   void           (*select_all)                    (GtkFileChooser    *chooser);
@@ -72,11 +74,13 @@ struct _GtkFileChooserIface
 };
 
 GtkFileSystem *_gtk_file_chooser_get_file_system         (GtkFileChooser    *chooser);
-void           _gtk_file_chooser_set_current_folder_path (GtkFileChooser    *chooser,
-                                                         const GtkFilePath *path);
+gboolean       _gtk_file_chooser_set_current_folder_path (GtkFileChooser    *chooser,
+                                                         const GtkFilePath *path,
+                                                         GError           **error);
 GtkFilePath *  _gtk_file_chooser_get_current_folder_path (GtkFileChooser    *chooser);
-void           _gtk_file_chooser_select_path             (GtkFileChooser    *chooser,
-                                                         const GtkFilePath *path);
+gboolean       _gtk_file_chooser_select_path             (GtkFileChooser    *chooser,
+                                                         const GtkFilePath *path,
+                                                         GError           **error);
 void           _gtk_file_chooser_unselect_path           (GtkFileChooser    *chooser,
                                                          const GtkFilePath *path);
 GSList *       _gtk_file_chooser_get_paths               (GtkFileChooser    *chooser);
index 653f196a8768e4c22be8a7abbf9f8915c22fa3ee..f957771888f89c25895b459604dac99ea5651c85 100644 (file)
 #include "gtkfilesystem.h"
 #include "gtktypebuiltins.h"
 
-static void           delegate_set_current_folder     (GtkFileChooser    *chooser,
-                                                      const GtkFilePath *path);
+static gboolean       delegate_set_current_folder     (GtkFileChooser    *chooser,
+                                                      const GtkFilePath *path,
+                                                      GError           **error);
 static GtkFilePath *  delegate_get_current_folder     (GtkFileChooser    *chooser);
 static void           delegate_set_current_name       (GtkFileChooser    *chooser,
                                                       const gchar       *name);
-static void           delegate_select_path            (GtkFileChooser    *chooser,
-                                                      const GtkFilePath *path);
+static gboolean       delegate_select_path            (GtkFileChooser    *chooser,
+                                                      const GtkFilePath *path,
+                                                      GError           **error);
 static void           delegate_unselect_path          (GtkFileChooser    *chooser,
                                                       const GtkFilePath *path);
 static void           delegate_select_all             (GtkFileChooser    *chooser);
@@ -65,7 +67,7 @@ static void           delegate_file_activated         (GtkFileChooser    *choose
 /**
  * _gtk_file_chooser_install_properties:
  * @klass: the class structure for a type deriving from #GObject
- * 
+ *
  * Installs the necessary properties for a class implementing
  * #GtkFileChooser. A #GtkParamSpecOverride property is installed
  * for each property, using the values from the #GtkFileChooserProp
@@ -111,7 +113,7 @@ _gtk_file_chooser_install_properties (GObjectClass *klass)
 /**
  * _gtk_file_chooser_delegate_iface_init:
  * @iface: a #GtkFileChoserIface structure
- * 
+ *
  * An interface-initialization function for use in cases where
  * an object is simply delegating the methods, signals of
  * the #GtkFileChooser interface to another object.
@@ -157,7 +159,7 @@ _gtk_file_chooser_set_delegate (GtkFileChooser *receiver,
 {
   g_return_if_fail (GTK_IS_FILE_CHOOSER (receiver));
   g_return_if_fail (GTK_IS_FILE_CHOOSER (delegate));
-  
+
   g_object_set_data (G_OBJECT (receiver), "gtk-file-chooser-delegate", delegate);
 
   g_signal_connect (delegate, "notify",
@@ -178,11 +180,12 @@ get_delegate (GtkFileChooser *receiver)
   return g_object_get_data (G_OBJECT (receiver), "gtk-file-chooser-delegate");
 }
 
-static void
+static gboolean
 delegate_select_path (GtkFileChooser    *chooser,
-                     const GtkFilePath *path)
+                     const GtkFilePath *path,
+                     GError           **error)
 {
-  _gtk_file_chooser_select_path (get_delegate (chooser), path);
+  return _gtk_file_chooser_select_path (get_delegate (chooser), path, error);
 }
 
 static void
@@ -264,11 +267,12 @@ delegate_list_shortcut_folders (GtkFileChooser *chooser)
   return gtk_file_chooser_list_shortcut_folders (get_delegate (chooser));
 }
 
-static void
+static gboolean
 delegate_set_current_folder (GtkFileChooser    *chooser,
-                            const GtkFilePath *path)
+                            const GtkFilePath *path,
+                            GError           **error)
 {
-  _gtk_file_chooser_set_current_folder_path (get_delegate (chooser), path);
+  return _gtk_file_chooser_set_current_folder_path (get_delegate (chooser), path, error);
 }
 
 static GtkFilePath *